home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / GBPVRSchedule.cs654 < prev    next >
Text File  |  2007-07-14  |  33KB  |  824 lines

  1. using System;
  2. using System.Collections;
  3. using GBPVR.Backend.Common;
  4. using GBPVR.Public;
  5.  
  6. namespace GBPVRSchedule
  7. {
  8.     /// <summary>
  9.     /// Summary description for GBPVRSchedule.
  10.     /// </summary>
  11.     public class GBPVRSchedule : Schedule
  12.     {
  13.         public GBPVRSchedule()
  14.         {
  15.             //
  16.             // TODO: Add constructor logic here
  17.             //
  18.             // RecordingFactor.getInstance() is not thread safe, so try and invoke it early where we're pretty sure we're single threaded
  19.             LoadRecordingSchedule();
  20.         }
  21.  
  22.         private IScheduleHelper scheduleHelper
  23.         {
  24.             get
  25.             {
  26.                 return ScheduleHelper.getInstance();
  27.             }
  28.         }
  29.  
  30.         public override IList LoadRecordingSchedule()
  31.         {
  32.             return scheduleHelper.LoadRecordingSchedule();
  33.         }
  34.  
  35.         public override Programme GetProgrammeByOID(int oid)
  36.         {
  37.             return scheduleHelper.GetProgrammeByOID(oid);
  38.         }
  39.  
  40.         public override Channel GetChannelByOID(int oid)
  41.         {
  42.             // Can't use the interface for GetChannelByOID yet
  43.             return ScheduleHelper.getInstance().GetChannelByOID(oid);
  44.         }
  45.  
  46.         public override void CreateReminder(Programme programme)
  47.         {
  48.             scheduleHelper.CreateReminder(programme);
  49.         }
  50.  
  51.         public override void RemoveReminder(Programme programme)
  52.         {
  53.             scheduleHelper.RemoveReminder(programme);
  54.         }
  55.  
  56.         public override ArrayList GetReminderList()
  57.         {
  58.             return scheduleHelper.GetReminderList();
  59.         }
  60.  
  61.         public override void UpdateScheduledRecording(ScheduledRecording scheduledRecording)
  62.         {
  63.             scheduleHelper.UpdateScheduledRecording(scheduledRecording);
  64.         }
  65.  
  66.         public override void CancelScheduledRecording(ScheduledRecording scheduledRecording)
  67.         {
  68.             scheduleHelper.CancelScheduledRecording(scheduledRecording);
  69.         }
  70.  
  71.         public override IList GetListingsForTimePeriod(DateTime startTime, DateTime endTime)
  72.         {
  73.             return scheduleHelper.GetListingsForTimePeriod(startTime, endTime);
  74.         }
  75.  
  76.         public override ScheduledRecording GetScheduledRecordingByOID(int oid)
  77.         {
  78.             return scheduleHelper.GetScheduledRecordingByOID(oid);
  79.             //    // Can't use the interface for GetScheduledRecordingByOID yet
  80.             //    IList myScheduledRecordings = scheduleHelper.LoadRecordingSchedule();                    
  81.             //    foreach (ScheduledRecording scheduledRecording in myScheduledRecordings)
  82.             //    {
  83.             //        if (scheduledRecording.getOID() == oid)
  84.             //        {                            
  85.             //            return scheduledRecording;
  86.             //        }
  87.             //    }
  88.             //    return null;
  89.         }
  90.  
  91.         public override bool ScheduleOnce(Programme programme, int PrePad, int PostPad)
  92.         {
  93.             ScheduledRecording myRecording = new ScheduledRecording();
  94.             try
  95.             {
  96.                 myRecording = scheduleHelper.SheduleRecording(
  97.                     programme.getChannelOID(),
  98.                     programme.getStartTime(),
  99.                     programme.getEndTime(),
  100.                     programme,
  101.                     ScheduledRecording.TYPE_RECORD_ONCE,
  102.                     ScheduledRecording.GROUP_NONE,
  103.                     null);
  104.                 if (PrePad > 0 || PostPad > 0)
  105.                 {
  106.                     myRecording.setPrePadMinutes(PrePad);
  107.                     myRecording.setPostPadMinutes(PostPad);
  108.                     scheduleHelper.UpdateScheduledRecording(myRecording);
  109.                 }
  110.             }
  111.             catch (Exception e1)
  112.             {
  113.                 Logger.Error("Recording not scheduled due to an error......");
  114.                 Logger.Error("Error: " + e1.Message);
  115.                 return false;
  116.             }
  117.  
  118.             if (myRecording != null)
  119.             {
  120.                 try
  121.                 {
  122.                     if (myRecording.getRecordingStatus().Equals(Status.Completed_Error) ||
  123.                         myRecording.getRecordingStatus().Equals(Status.Conflict))
  124.                     {
  125.                         if (myRecording.getRecordingStatus().Equals(Status.Completed_Error))
  126.                         {
  127.                             Logger.Error("Recording not scheduled.  Status is Completed with Error.");
  128.                         }
  129.                         else
  130.                         {
  131.                             Logger.Error("Recording not scheduled.  Status is Conflict.");
  132.                         }
  133.                         return false;
  134.                     }
  135.                     else
  136.                     {
  137.                         return true;
  138.                     }
  139.                 }
  140.                 catch (Exception e2)
  141.                 {
  142.                     Logger.Error("Recording not scheduled due to an error......");
  143.                     Logger.Error("Error: " + e2.Message);
  144.                     return false;
  145.                 }
  146.             }
  147.             else
  148.             {
  149.                 Logger.Error("Recording not scheduled.  Recording not found after calling GBPVR API to schedule the programme.");
  150.                 return false;
  151.             }
  152.         }
  153.  
  154.         public override bool ScheduleOnce(Programme programme, Quality quality, int PrePad, int PostPad)
  155.         {
  156.             ScheduledRecording myRecording = new ScheduledRecording();
  157.             try
  158.             {
  159.                 myRecording = scheduleHelper.SheduleRecording(
  160.                     programme.getChannelOID(),
  161.                     programme.getStartTime(),
  162.                     programme.getEndTime(),
  163.                     programme,
  164.                     ScheduledRecording.TYPE_RECORD_ONCE,
  165.                     ScheduledRecording.GROUP_NONE,
  166.                     null,
  167.                     (int) quality);
  168.                 if (PrePad > 0 || PostPad > 0)
  169.                 {
  170.                     myRecording.setPrePadMinutes(PrePad);
  171.                     myRecording.setPostPadMinutes(PostPad);
  172.                     scheduleHelper.UpdateScheduledRecording(myRecording);
  173.                 }
  174.             }
  175.             catch (Exception e1)
  176.             {
  177.                 Logger.Error("Recording not scheduled due to an error......");
  178.                 Logger.Error("Error: " + e1.Message);
  179.                 return false;
  180.             }
  181.  
  182.             if (myRecording != null)
  183.             {
  184.                 try
  185.                 {
  186.                     if (myRecording.getRecordingStatus().Equals(Status.Completed_Error) ||
  187.                         myRecording.getRecordingStatus().Equals(Status.Conflict))
  188.                     {
  189.                         if (myRecording.getRecordingStatus().Equals(Status.Completed_Error))
  190.                         {
  191.                             Logger.Error("Recording not scheduled.  Status is Completed with Error.");
  192.                         }
  193.                         else
  194.                         {
  195.                             Logger.Error("Recording not scheduled.  Status is Conflict.");
  196.                         }
  197.                         return false;
  198.                     }
  199.                     else
  200.                     {
  201.                         return true;
  202.                     }
  203.                 }
  204.                 catch (Exception e2)
  205.                 {
  206.                     Logger.Error("Recording not scheduled due to an error......");
  207.                     Logger.Error("Error: " + e2.Message);
  208.                     return false;
  209.                 }
  210.             }
  211.             else
  212.             {
  213.                 Logger.Error("Recording not scheduled.  Recording not found after calling GBPVR API to schedule the programme.");
  214.                 return false;
  215.             }
  216.     }
  217.  
  218.         public override bool ScheduleAnyTime(Programme programme, RecType type, int PrePad, int PostPad)
  219.         {
  220.             ScheduledRecording myRecording = new ScheduledRecording();
  221.             try
  222.             {
  223.                 DateTime startTime = DateTime.MinValue;
  224.                 DateTime endTime = DateTime.MinValue;
  225.  
  226.                 myRecording = scheduleHelper.SheduleRecording(
  227.                     programme.getChannelOID(),
  228.                     startTime,
  229.                     endTime,
  230.                     null,
  231.                     (int)type,
  232.                     ScheduledRecording.GROUP_ALLOCATE,
  233.                     programme.getTitle());
  234.                 if (PrePad > 0 || PostPad > 0)
  235.                 {
  236.                     myRecording.setPrePadMinutes(PrePad);
  237.                     myRecording.setPostPadMinutes(PostPad);
  238.                     scheduleHelper.UpdateScheduledRecording(myRecording);
  239.                 }
  240.             }
  241.             catch (Exception e1)
  242.             {
  243.                 Logger.Error("Recording not scheduled due to an error......");
  244.                 Logger.Error("Error: " + e1.Message);
  245.                 return false;
  246.             }
  247.  
  248.             if (myRecording != null)
  249.             {
  250.                 try
  251.                 {
  252.                     if (myRecording.getRecordingStatus().Equals(Status.Completed_Error) ||
  253.                         myRecording.getRecordingStatus().Equals(Status.Conflict))
  254.                     {
  255.                         if (myRecording.getRecordingStatus().Equals(Status.Completed_Error))
  256.                         {
  257.                             Logger.Error("Recording not scheduled.  Status is Completed with Error.");
  258.                         }
  259.                         else
  260.                         {
  261.                             Logger.Error("Recording not scheduled.  Status is Conflict.");
  262.                         }
  263.                         return false;
  264.                     }
  265.                     else
  266.                     {
  267.                         return true;
  268.                     }
  269.                 }
  270.                 catch (Exception e2)
  271.                 {
  272.                     Logger.Error("Recording not scheduled due to an error......");
  273.                     Logger.Error("Error: " + e2.Message);
  274.                     return false;
  275.                 }
  276.             }
  277.             else
  278.             {
  279.                 Logger.Error("Recording not scheduled.  Recording not found after calling GBPVR API to schedule the programme.");
  280.                 return false;
  281.             }
  282.         }
  283.  
  284.         public override bool ScheduleAnyTime(Programme programme, Quality quality, RecType type, int PrePad, int PostPad)
  285.         {
  286.             ScheduledRecording myRecording = new ScheduledRecording();
  287.             try
  288.             {
  289.                 DateTime startTime = DateTime.MinValue;
  290.                 DateTime endTime = DateTime.MinValue;
  291.  
  292.                 myRecording = scheduleHelper.SheduleRecording(
  293.                     programme.getChannelOID(),
  294.                     startTime,
  295.                     endTime,
  296.                     null,
  297.                     (int)type,
  298.                     ScheduledRecording.GROUP_ALLOCATE,
  299.                     programme.getTitle(),
  300.                     (int)quality);
  301.                 if (PrePad > 0 || PostPad > 0)
  302.                 {
  303.                     myRecording.setPrePadMinutes(PrePad);
  304.                     myRecording.setPostPadMinutes(PostPad);
  305.                     scheduleHelper.UpdateScheduledRecording(myRecording);
  306.                 }
  307.             }
  308.             catch (Exception e1)
  309.             {
  310.                 Logger.Error("Recording not scheduled due to an error......");
  311.                 Logger.Error("Error: " + e1.Message);
  312.                 return false;
  313.             }
  314.  
  315.             if (myRecording != null)
  316.             {
  317.                 try
  318.                 {
  319.                     if (myRecording.getRecordingStatus().Equals(Status.Completed_Error) ||
  320.                         myRecording.getRecordingStatus().Equals(Status.Conflict))
  321.                     {
  322.                         if (myRecording.getRecordingStatus().Equals(Status.Completed_Error))
  323.                         {
  324.                             Logger.Error("Recording not scheduled.  Status is Completed with Error.");
  325.                         }
  326.                         else
  327.                         {
  328.                             Logger.Error("Recording not scheduled.  Status is Conflict.");
  329.                         }
  330.                         return false;
  331.                     }
  332.                     else
  333.                     {
  334.                         return true;
  335.                     }
  336.                 }
  337.                 catch (Exception e2)
  338.                 {
  339.                     Logger.Error("Recording not scheduled due to an error......");
  340.                     Logger.Error("Error: " + e2.Message);
  341.                     return false;
  342.                 }
  343.             }
  344.             else
  345.             {
  346.                 Logger.Error("Recording not scheduled.  Recording not found after calling GBPVR API to schedule the programme.");
  347.                 return false;
  348.             }
  349.         }
  350.  
  351.         public override bool ScheduleAnyTime(Programme programme, Quality quality, DayType dayType, int keepnumRecordings, RecType type, int PrePad, int PostPad)
  352.         {
  353.             ScheduledRecording myRecording = new ScheduledRecording();
  354.             try
  355.             {
  356.                 DateTime startTime = DateTime.MinValue;
  357.                 DateTime endTime = DateTime.MinValue;
  358.  
  359.                 switch (dayType)
  360.                 {
  361.                     case DayType.SheduleAnyDay:
  362.                         myRecording = scheduleHelper.SheduleRecording(programme.getChannelOID(),
  363.                             startTime,
  364.                             endTime,
  365.                             null,
  366.                             (int)type,
  367.                             ScheduledRecording.GROUP_ALLOCATE,
  368.                             programme.getTitle(),
  369.                             (int)quality,
  370.                             keepnumRecordings,
  371.                             ReoccuringRecordingExtras.DAY_SUNDAY |
  372.                             ReoccuringRecordingExtras.DAY_MONDAY |
  373.                             ReoccuringRecordingExtras.DAY_TUESDAY |
  374.                             ReoccuringRecordingExtras.DAY_WEDNESDAY |
  375.                             ReoccuringRecordingExtras.DAY_THURSDAY |
  376.                             ReoccuringRecordingExtras.DAY_FRIDAY |
  377.                             ReoccuringRecordingExtras.DAY_SATURDAY,
  378.                             PrePad,
  379.                             PostPad);
  380.                         break;
  381.                     case DayType.SheduleThisDay:
  382.                         int day = (int)Math.Pow(2, (int)programme.getStartTime().DayOfWeek);
  383.                         myRecording = scheduleHelper.SheduleRecording(programme.getChannelOID(),
  384.                             startTime,
  385.                             endTime,
  386.                             null,
  387.                             (int)type,
  388.                             ScheduledRecording.GROUP_ALLOCATE,
  389.                             programme.getTitle(),
  390.                             (int)quality,
  391.                             keepnumRecordings,
  392.                             day,
  393.                             PrePad,
  394.                             PostPad);
  395.                         break;
  396.                     default:
  397.                         return false;
  398.                 }
  399.             }
  400.             catch (Exception e1)
  401.             {
  402.                 Logger.Error("Recording not scheduled due to an error......");
  403.                 Logger.Error("Error: " + e1.Message);
  404.                 return false;
  405.             }
  406.  
  407.             if (myRecording != null)
  408.             {
  409.                 try
  410.                 {
  411.                     if (myRecording.getRecordingStatus().Equals(Status.Completed_Error) ||
  412.                         myRecording.getRecordingStatus().Equals(Status.Conflict))
  413.                     {
  414.                         if (myRecording.getRecordingStatus().Equals(Status.Completed_Error))
  415.                         {
  416.                             Logger.Error("Recording not scheduled.  Status is Completed with Error.");
  417.                         }
  418.                         else
  419.                         {
  420.                             Logger.Error("Recording not scheduled.  Status is Conflict.");
  421.                         }
  422.                         return false;
  423.                     }
  424.                     else
  425.                     {
  426.                         return true;
  427.                     }
  428.                 }
  429.                 catch (Exception e2)
  430.                 {
  431.                     Logger.Error("Recording not scheduled due to an error......");
  432.                     Logger.Error("Error: " + e2.Message);
  433.                     return false;
  434.                 }
  435.             }
  436.             else
  437.             {
  438.                 Logger.Error("Recording not scheduled.  Recording not found after calling GBPVR API to schedule the programme.");
  439.                 return false;
  440.             }
  441.         }
  442.  
  443.         public override bool ScheduleAnyTime(Programme programme, Quality quality, DayType dayType, int keepnumRecordings, ArrayList days, RecType type, int PrePad, int PostPad)
  444.         {
  445.             ScheduledRecording myRecording = new ScheduledRecording();
  446.             try
  447.             {
  448.                 switch (dayType)
  449.                 {
  450.                     case DayType.SheduleSpecificDays:
  451.                         DateTime startTime = DateTime.MinValue;
  452.                         DateTime endTime = DateTime.MinValue;
  453.  
  454.                         Day day = 0;
  455.                         // Iterate through the ArrayList of days to create the daymask for the recording
  456.                         for (int i = 0; i < days.Count; i++)
  457.                         {
  458.                             day = day | (Day)days[i];
  459.                         }
  460.                         myRecording = scheduleHelper.SheduleRecording(programme.getChannelOID(),
  461.                             startTime,
  462.                             endTime,
  463.                             null,
  464.                             (int)type,
  465.                             ScheduledRecording.GROUP_ALLOCATE,
  466.                             programme.getTitle(),
  467.                             (int)quality,
  468.                             keepnumRecordings,
  469.                             (int)day,
  470.                             PrePad,
  471.                             PostPad);
  472.                         break;
  473.                     default:
  474.                         return false;
  475.                 }
  476.             }
  477.             catch (Exception e1)
  478.             {
  479.                 Logger.Error("Recording not scheduled due to an error......");
  480.                 Logger.Error("Error: " + e1.Message);
  481.                 return false;
  482.             }
  483.  
  484.             if (myRecording != null)
  485.             {
  486.                 try
  487.                 {
  488.                     if (myRecording.getRecordingStatus().Equals(Status.Completed_Error) ||
  489.                         myRecording.getRecordingStatus().Equals(Status.Conflict))
  490.                     {
  491.                         if (myRecording.getRecordingStatus().Equals(Status.Completed_Error))
  492.                         {
  493.                             Logger.Error("Recording not scheduled.  Status is Completed with Error.");
  494.                         }
  495.                         else
  496.                         {
  497.                             Logger.Error("Recording not scheduled.  Status is Conflict.");
  498.                         }
  499.                         return false;
  500.                     }
  501.                     else
  502.                     {
  503.                         return true;
  504.                     }
  505.                 }
  506.                 catch (Exception e2)
  507.                 {
  508.                     Logger.Error("Recording not scheduled due to an error......");
  509.                     Logger.Error("Error: " + e2.Message);
  510.                     return false;
  511.                 }
  512.             }
  513.             else
  514.             {
  515.                 Logger.Error("Recording not scheduled.  Recording not found after calling GBPVR API to schedule the programme.");
  516.                 return false;
  517.             }
  518.         }
  519.  
  520.         public override bool ScheduleThisTime(Programme programme, RecType type, int PrePad, int PostPad)
  521.         {
  522.             ScheduledRecording myRecording = new ScheduledRecording();
  523.             try
  524.             {
  525.                 DateTime startTime = programme.getStartTime();
  526.                 DateTime endTime = programme.getEndTime();
  527.  
  528.                 myRecording = scheduleHelper.SheduleRecording(
  529.                     programme.getChannelOID(),
  530.                     startTime,
  531.                     endTime,
  532.                     null,
  533.                     (int)type,
  534.                     ScheduledRecording.GROUP_ALLOCATE,
  535.                     programme.getTitle());
  536.                 if (PrePad > 0 || PostPad > 0)
  537.                 {
  538.                     myRecording.setPrePadMinutes(PrePad);
  539.                     myRecording.setPostPadMinutes(PostPad);
  540.                     scheduleHelper.UpdateScheduledRecording(myRecording);
  541.                 }
  542.             }
  543.             catch (Exception e1)
  544.             {
  545.                 Logger.Error("Recording not scheduled due to an error......");
  546.                 Logger.Error("Error: " + e1.Message);
  547.                 return false;
  548.             }
  549.  
  550.             if (myRecording != null)
  551.             {
  552.                 try
  553.                 {
  554.                     if (myRecording.getRecordingStatus().Equals(Status.Completed_Error) ||
  555.                         myRecording.getRecordingStatus().Equals(Status.Conflict))
  556.                     {
  557.                         if (myRecording.getRecordingStatus().Equals(Status.Completed_Error))
  558.                         {
  559.                             Logger.Error("Recording not scheduled.  Status is Completed with Error.");
  560.                         }
  561.                         else
  562.                         {
  563.                             Logger.Error("Recording not scheduled.  Status is Conflict.");
  564.                         }
  565.                         return false;
  566.                     }
  567.                     else
  568.                     {
  569.                         return true;
  570.                     }
  571.                 }
  572.                 catch (Exception e2)
  573.                 {
  574.                     Logger.Error("Recording not scheduled due to an error......");
  575.                     Logger.Error("Error: " + e2.Message);
  576.                     return false;
  577.                 }
  578.             }
  579.             else
  580.             {
  581.                 Logger.Error("Recording not scheduled.  Recording not found after calling GBPVR API to schedule the programme.");
  582.                 return false;
  583.             }
  584.         }
  585.  
  586.         public override bool ScheduleThisTime(Programme programme, Quality quality, RecType type, int PrePad, int PostPad)
  587.         {
  588.             ScheduledRecording myRecording = new ScheduledRecording();
  589.             try
  590.             {
  591.                 DateTime startTime = programme.getStartTime();
  592.                 DateTime endTime = programme.getEndTime();
  593.  
  594.                 myRecording = scheduleHelper.SheduleRecording(
  595.                     programme.getChannelOID(),
  596.                     startTime,
  597.                     endTime,
  598.                     null,
  599.                     (int)type,
  600.                     ScheduledRecording.GROUP_ALLOCATE,
  601.                     programme.getTitle(),
  602.                     (int)quality);
  603.                 if (PrePad > 0 || PostPad > 0)
  604.                 {
  605.                     myRecording.setPrePadMinutes(PrePad);
  606.                     myRecording.setPostPadMinutes(PostPad);
  607.                     scheduleHelper.UpdateScheduledRecording(myRecording);
  608.                 }
  609.             }
  610.             catch (Exception e1)
  611.             {
  612.                 Logger.Error("Recording not scheduled due to an error......");
  613.                 Logger.Error("Error: " + e1.Message);
  614.                 return false;
  615.             }
  616.  
  617.             if (myRecording != null)
  618.             {
  619.                 try
  620.                 {
  621.                     if (myRecording.getRecordingStatus().Equals(Status.Completed_Error) ||
  622.                         myRecording.getRecordingStatus().Equals(Status.Conflict))
  623.                     {
  624.                         if (myRecording.getRecordingStatus().Equals(Status.Completed_Error))
  625.                         {
  626.                             Logger.Error("Recording not scheduled.  Status is Completed with Error.");
  627.                         }
  628.                         else
  629.                         {
  630.                             Logger.Error("Recording not scheduled.  Status is Conflict.");
  631.                         }
  632.                         return false;
  633.                     }
  634.                     else
  635.                     {
  636.                         return true;
  637.                     }
  638.                 }
  639.                 catch (Exception e2)
  640.                 {
  641.                     Logger.Error("Recording not scheduled due to an error......");
  642.                     Logger.Error("Error: " + e2.Message);
  643.                     return false;
  644.                 }
  645.             }
  646.             else
  647.             {
  648.                 Logger.Error("Recording not scheduled.  Recording not found after calling GBPVR API to schedule the programme.");
  649.                 return false;
  650.             }
  651.         }
  652.  
  653.         public override bool ScheduleThisTime(Programme programme, Quality quality, DayType dayType, int keepnumRecordings, RecType type, int PrePad, int PostPad)
  654.         {
  655.             ScheduledRecording myRecording = new ScheduledRecording();
  656.             try
  657.             {
  658.                 DateTime startTime = programme.getStartTime();
  659.                 DateTime endTime = programme.getEndTime();
  660.  
  661.                 switch (dayType)
  662.                 {
  663.                     case DayType.SheduleAnyDay:
  664.                         myRecording = scheduleHelper.SheduleRecording(programme.getChannelOID(),
  665.                             startTime,
  666.                             endTime,
  667.                             null,
  668.                             (int)type,
  669.                             ScheduledRecording.GROUP_ALLOCATE,
  670.                             programme.getTitle(),
  671.                             (int)quality,
  672.                             keepnumRecordings,
  673.                             ReoccuringRecordingExtras.DAY_SUNDAY |
  674.                             ReoccuringRecordingExtras.DAY_MONDAY |
  675.                             ReoccuringRecordingExtras.DAY_TUESDAY |
  676.                             ReoccuringRecordingExtras.DAY_WEDNESDAY |
  677.                             ReoccuringRecordingExtras.DAY_THURSDAY |
  678.                             ReoccuringRecordingExtras.DAY_FRIDAY |
  679.                             ReoccuringRecordingExtras.DAY_SATURDAY,
  680.                             PrePad,
  681.                             PostPad);
  682.                         break;
  683.                     case DayType.SheduleThisDay:
  684.                         int day = (int)Math.Pow(2, (int)programme.getStartTime().DayOfWeek);
  685.                         myRecording = scheduleHelper.SheduleRecording(programme.getChannelOID(),
  686.                             startTime,
  687.                             endTime,
  688.                             null,
  689.                             (int)type,
  690.                             ScheduledRecording.GROUP_ALLOCATE,
  691.                             programme.getTitle(),
  692.                             (int)quality,
  693.                             keepnumRecordings,
  694.                             day,
  695.                             PrePad,
  696.                             PostPad);
  697.                         break;
  698.                     default:
  699.                         return false;
  700.                 }
  701.             }
  702.             catch (Exception e1)
  703.             {
  704.                 Logger.Error("Recording not scheduled due to an error......");
  705.                 Logger.Error("Error: " + e1.Message);
  706.                 return false;
  707.             }
  708.  
  709.             if (myRecording != null)
  710.             {
  711.                 try
  712.                 {
  713.                     if (myRecording.getRecordingStatus().Equals(Status.Completed_Error) ||
  714.                         myRecording.getRecordingStatus().Equals(Status.Conflict))
  715.                     {
  716.                         if (myRecording.getRecordingStatus().Equals(Status.Completed_Error))
  717.                         {
  718.                             Logger.Error("Recording not scheduled.  Status is Completed with Error.");
  719.                         }
  720.                         else
  721.                         {
  722.                             Logger.Error("Recording not scheduled.  Status is Conflict.");
  723.                         }
  724.                         return false;
  725.                     }
  726.                     else
  727.                     {
  728.                         return true;
  729.                     }
  730.                 }
  731.                 catch (Exception e2)
  732.                 {
  733.                     Logger.Error("Recording not scheduled due to an error......");
  734.                     Logger.Error("Error: " + e2.Message);
  735.                     return false;
  736.                 }
  737.             }
  738.             else
  739.             {
  740.                 Logger.Error("Recording not scheduled.  Recording not found after calling GBPVR API to schedule the programme.");
  741.                 return false;
  742.             }
  743.         }
  744.  
  745.         public override bool ScheduleThisTime(Programme programme, Quality quality, DayType dayType, int keepnumRecordings, ArrayList days, RecType type, int PrePad, int PostPad)
  746.         {
  747.             ScheduledRecording myRecording = new ScheduledRecording();
  748.             try
  749.             {
  750.                 DateTime startTime = programme.getStartTime();
  751.                 DateTime endTime = programme.getEndTime();
  752.  
  753.                 switch (dayType)
  754.                 {
  755.                     case DayType.SheduleSpecificDays:
  756.                         Day day = 0;
  757.                         // Iterate through the ArrayList of days to create the daymask for the recording
  758.                         for (int i = 0; i < days.Count; i++)
  759.                         {
  760.                             day = day | (Day)days[i];
  761.                         }
  762.                         myRecording = scheduleHelper.SheduleRecording(programme.getChannelOID(),
  763.                             startTime,
  764.                             endTime,
  765.                             null,
  766.                             (int)type,
  767.                             ScheduledRecording.GROUP_ALLOCATE,
  768.                             programme.getTitle(),
  769.                             (int)quality,
  770.                             keepnumRecordings,
  771.                             (int)day,
  772.                             PrePad,
  773.                             PostPad);
  774.                         break;
  775.  
  776.                     default:
  777.                         return false;
  778.                 }
  779.             }
  780.             catch (Exception e1)
  781.             {
  782.                 Logger.Error("Recording not scheduled due to an error......");
  783.                 Logger.Error("Error: " + e1.Message);
  784.                 return false;
  785.             }
  786.  
  787.             if (myRecording != null)
  788.             {
  789.                 try
  790.                 {
  791.                     if (myRecording.getRecordingStatus().Equals(Status.Completed_Error) ||
  792.                         myRecording.getRecordingStatus().Equals(Status.Conflict))
  793.                     {
  794.                         if (myRecording.getRecordingStatus().Equals(Status.Completed_Error))
  795.                         {
  796.                             Logger.Error("Recording not scheduled.  Status is Completed with Error.");
  797.                         }
  798.                         else
  799.                         {
  800.                             Logger.Error("Recording not scheduled.  Status is Conflict.");
  801.                         }
  802.                         return false;
  803.                     }
  804.                     else
  805.                     {
  806.                         return true;
  807.                     }
  808.                 }
  809.                 catch (Exception e2)
  810.                 {
  811.                     Logger.Error("Recording not scheduled due to an error......");
  812.                     Logger.Error("Error: " + e2.Message);
  813.                     return false;
  814.                 }
  815.             }
  816.             else
  817.             {
  818.                 Logger.Error("Recording not scheduled.  Recording not found after calling GBPVR API to schedule the programme.");
  819.                 return false;
  820.             }
  821.         }
  822.     }
  823. }
  824.